<?php

class Application_Model_Dao_Order extends Zend_Db_Table_Abstract
{

	protected $_name = 'orders';
    protected $_primary = 'id';
    	
	public function init(){
    	
    }
    
 	public function getAll(){
		$result = $this->fetchAll();
		if( !$result )
			throw new Exception("Wystąpił błąd przy pobieraniu danych z bazy. Proszę spróbować jeszcze raz. Jeśli problem będzie się powtarzać, prosimy skontaktować się z administratorem.");	
		return $result;
    } 
	public function getOrderByID($id){
		$id = (int)$id;
		$row = $this->fetchRow('id = '.$id);
		if (!$row)
			throw new Exception("Zamówienie o ID $id nie istnieje.");
		return $row->toArray();
	}


	public function saveOrder($order) {
    	$data = array(
			'subject_id' => $order->getSubject(),
    		'speciality_id' => $order->getSpeciality(),
			'numberWeek' => $order->getNumberWeek(),
    		'dimensionSemester' => $order->getDimensionSemester(),
    		'hourYear' => $order->getHourYear(),
    		'hourSemester' => $order->getHourSemester(),
    		'year_id' => $order->getYear(),
		);
		$this->insert($data);
     return ;
    }
public function getToSelect(){
    	$array = $this->getAll()->toArray();
    	$orders[''] = "wybierz";
    	foreach ($array as $option) {
     	//$degreeStudies[ $option['id'] ] = $option['designation' ] ;
     }
     return $orders;
    }
}